package Logic;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class CalendarMethods
{
	public static Calendar formatStringToDate(String dd_mmm_yyyy)
	{
		Calendar cal = Calendar.getInstance();
		int year = Integer.parseInt(dd_mmm_yyyy.substring(7,11));
		
		int month = -1;
		String monthS = dd_mmm_yyyy.substring(3,6);
		if(monthS.equals("JAN")) month = 0;
		else if(monthS.equals("FEB")) month = 1;
		else if(monthS.equals("MAR")) month = 2;
		else if(monthS.equals("APR")) month = 3;
		else if(monthS.equals("MAY")) month = 4;
		else if(monthS.equals("JUN")) month = 5;
		else if(monthS.equals("JUL")) month = 6;
		else if(monthS.equals("AUG")) month = 7;
		else if(monthS.equals("SEP")) month = 8;
		else if(monthS.equals("OCT")) month = 9;
		else if(monthS.equals("NOV")) month = 10;
		else if(monthS.equals("DEC")) month = 11;
		
		int date = Integer.parseInt(dd_mmm_yyyy.substring(0,2));
		
		cal.set(year, month, date);
		
		return cal;
		
		//SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
		//System.out.println(sdf.format(cal.getTime()));
	}
	
	public static String formatDateToString(Calendar cal)
	{
		
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
		return sdf.format(cal.getTime());
	}
}
